/*
 *	DjoltFilter.m
 *
 *	David Janes
 *	Discover Anywhere Mobile
 *	March 2010
 *
 *	Copyright 2010 Discover Anywhere Mobile
 */

#import "DjoltFilter.h"
#import "DjoltContext.h"

@implementation DjoltFilter
@synthesize filter;
@synthesize argument;

- (id) initWithFilter:(NSString*)_filter argument:(NSString*)_argument;
{
    if (self = [super init]) {
		filter = _filter;
		argument = _argument;
	}

	return	self;
}

- (NSString*) filter:(NSString*)_value context:(DjoltContext*)_context
{
	return	[self
		performSelector:NSSelectorFromString([NSString stringWithFormat:@"_filter_%@:context:", filter])
		withObject:_value
		withObject:_context
	];
	
	return	_value;
}

- (NSString*) _filter_default:(NSString*)_value context:(DjoltContext*)_context
{
	return	argument;
}

- (NSString*) _filter_upper:(NSString*)_value context:(DjoltContext*)_context
{
	return	[_value uppercaseString];
}

- (NSString*) _filter_lower:(NSString*)_value context:(DjoltContext*)_context
{
	return	[_value lowercaseString];
}
@end
